API Endpoints
Base route: /notification-preferences
1. Get Opt-Out Details
Method: GET
Path: /notification-preferences/opt-out/:token
Authentication: No
Description:
Retrieves customer, notification type, and service information by decoding a secure token.
Path Parameters:
token— Encrypted string containing opt-out info.
Response:
{
"customer": {
"id": "19215",
"firstName": "John",
"lastName": "Leonard"
},
"notificationType": "email",
"service": {
"id": 1,
"name": "rating"
}
}
2. Set Notification Preference
Method: POST
Path: /notification-preferences/set-preference
Authentication: Yes (Customer)
Description: Creates or updates a notification preference for the authenticated customer.
Headers:
Authorization: Bearer <token>
Request Body:
{
"customerId": 123,
"notificationServiceId": 456,
"notificationType": "email",
"reason": "No longer needed",
"status": "opted_out"
}
Notification Service Endpoints
These endpoints allow authenticated users to manage their notification services.
3. Add Notification Service
Method: POST
Path: /notification-preferences/add-service
Authentication: Yes
Description: Creates a new notification service for the authenticated user.
Headers:
Authorization: Bearer <token>
Request Body:
{
"name": "rating",
}
Response:
{
"name": "rating",
"createdBy": {
"id": "4642"
},
"id": 1,
"createdAt": "2025-05-19T06:28:18.703Z",
"updatedAt": "2025-05-19T06:28:18.703Z"
}
4. Update Notification Service
Method: PATCH
Path: /notification-preferences/update-service/:id
Authentication: Yes
Description:
Updates an existing notification service identified by its id for the authenticated user.
Headers:
Authorization: Bearer <token>
Path Parameters:
id— ID of the service to update.
Request Body:
{
"name": "ratings",
}
Response:
{
"id": 1,
"name": "ratings",
"createdAt": "2025-07-06T11:00:00.000Z",
"updatedAt": "2025-06-04T11:13:50.000Z",
"updatedBy": {
"id": "4642"
}
}
5. Get Notification Services
Method: GET
Path: /notification-preferences/services
Authentication: Yes
Description: Retrieves a list of all available notification services for the authenticated user.
Headers:
Authorization: Bearer <token>
Response:
[
{
"id": 2,
"name": "rating",
"createdAt": "2025-06-04T11:23:51.711Z",
"updatedAt": "2025-06-04T11:23:51.711Z",
"createdBy": {
"id": "4642",
"firstName": "Chinaemerem",
"lastName": "Umunnakwe"
},
"updatedBy": null
}
]